﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
using LTP.Accounts.Bus;
namespace Maticsoft.Web.GroupInfo
{
    public partial class Modify : Page
    {       

        		protected void Page_Load(object sender, EventArgs e)
		{
			if (!Page.IsPostBack)
			{
				if (Request.Params["id"] != null && Request.Params["id"].Trim() != "")
				{
					int GroupId=(Convert.ToInt32(Request.Params["id"]));
					ShowInfo(GroupId);
				}
			}
		}
			
	private void ShowInfo(int GroupId)
	{
		Maticsoft.BLL.GroupInfo bll=new Maticsoft.BLL.GroupInfo();
		Maticsoft.Model.GroupInfo model=bll.GetModel(GroupId);
		this.lblGroupId.Text=model.GroupId.ToString();
		this.txtGroupName.Text=model.GroupName;
		this.txtGroupDes.Text=model.GroupDes;

	}

		public void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtGroupName.Text.Trim().Length==0)
			{
				strErr+="GroupName不能为空！\\n";	
			}
			if(this.txtGroupDes.Text.Trim().Length==0)
			{
				strErr+="GroupDes不能为空！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			int GroupId=int.Parse(this.lblGroupId.Text);
			string GroupName=this.txtGroupName.Text;
			string GroupDes=this.txtGroupDes.Text;


			Maticsoft.Model.GroupInfo model=new Maticsoft.Model.GroupInfo();
			model.GroupId=GroupId;
			model.GroupName=GroupName;
			model.GroupDes=GroupDes;

			Maticsoft.BLL.GroupInfo bll=new Maticsoft.BLL.GroupInfo();
			bll.Update(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","list.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
